ransomNote = "aa", magazine = "aab"
var canConstruct = function(ransomNote, magazine) {
    let obj = new Map()
    for(let i=0;i<magazine.length;i++){
        if(obj.has(magazine[i])){
            obj.set(magazine[i],obj.get(magazine[i])+1)
        }else{
            
            obj.set(magazine[i],1)
        }
    }
     for(let j=0;j<ransomNote.length;j++){
        if(obj.has(ransomNote[j])){
            obj.set(ransomNote[j],obj.get(ransomNote[j])-1)
            if(obj.get(ransomNote[j])<0){
                return false
            }
        }else{
            return false
        }
    }
    return true 
};
console.log(canConstruct(ransomNote,magazine));